const app = getApp()

Page({
  data: {
    noticeList: []
  },
  onLoad () {
    let that = this
    that._acceptNoticeList().then((res) => {
      that.setData({
        noticeList: res.data.data
      })
    })
  },
  onPullDownRefresh () {
    wx.showNavigationBarLoading()
    let that = this
    console.log('--------上拉刷新-------')
    // that.page = 1
    that._acceptNoticeList().then((res) => {
      console.log(res)
      that.setData({
        noticeList: res.data.data
      })
      wx.hideNavigationBarLoading() //完成停止加载
      wx.stopPullDownRefresh() //停止下拉刷新
    }).catch((res) => {
      wx.hideNavigationBarLoading() //完成停止加载
      wx.stopPullDownRefresh() //停止下拉刷新
    })
  },
  _acceptNoticeList () {
    let that = this
    return new Promise ((resolve, reject) => {
      app.util.request({
        url: 'entry/wxapp/noticelist',
        success: (res) => {
          resolve(res)
        },
        fail: (res) => {
          reject(res)
        }
      })
    })
  },
})
